import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/Table';
import { airportList, getTiYanVipcardList } from '@apps/ant-bus/src/views/business/airport/data/api';
import { render } from '@apps/antd-admin/src/hooks/render/renderUtils';

export const columns: BasicColumn[] = [
  {
    title: '商家名称',
    dataIndex: 'shopName',
    width: 100,
  },
  {
    title: '商家图片',
    dataIndex: 'shopImg',
    width: 100,
    customRender: render.renderImage,
  }
];

export const searchFormSchema: FormSchema[] = [];

export const formSchema: FormSchema[] = [
  {
    label: '机场设置Id',
    field: 'airportGiveGoodsNumId',
    component: 'Input',
    required: false,
    ifShow: false,
  },
  {
    label: '机场',
    field: 'airportId',
    component: 'ApiSelect',
    required: true,
    dynamicDisabled: true,
    componentProps: {
      api: airportList,
      labelField: 'airportName',
      valueField: 'airportId',
      immediate: true,
      showSearch: true,
    },
  },
  {
    label: '产品',
    field: 'goodsId',
    component: 'ApiSelect',
    required: true,
    dynamicDisabled: ({ values }) => {
      if (values.airportGiveGoodsNumId) {
        return true;
      } else {
        return false;
      }
    },
    componentProps: ({ formModel }) => {
      return {
        api: getTiYanVipcardList,
        params: { airportId: formModel.airportId },
        labelField: 'goodsName',
        valueField: 'goodsId',
        immediate: true,
        showSearch: true,
      };
    },
  },
  {
    label: '可赠送数量',
    field: 'giveGoodsNum',
    component: 'InputNumber',
    required: true,
  },
];
